﻿using Manor.CslaDesigner;
using Microsoft.VisualStudio.Modeling;
using Microsoft.VisualStudio.Modeling.Design;
using Microsoft.VisualStudio.Modeling.Diagrams;
using System.Collections.Generic;
using System.Linq;

namespace Manor.CslaDesigner
{
    internal class ClickableImageField : ImageField
    {
        // You can also override OnClick and so on.
        public override void OnDoubleClick(DiagramPointEventArgs e)
        {
            base.OnDoubleClick(e);
            // Work out which instance was hit.
            ClassShape shapeHit = e.HitDiagramItem.Shape as ClassShape;
            if (shapeHit != null)
            {
                ModelClass element =
                    shapeHit.ModelElement as ModelClass;
                System.Windows.Forms.MessageBox.Show(
                    "Double click on shape for " + element.Name);
                // If we do not set Handled, the event will
                // be passed to the containing shape:
                e.Handled = true;
            }
        }

        public ClickableImageField(string fieldName)
            : base(fieldName)
        {
        }
    }

}